package com.ithaima.a_cookie.com.itheima.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

//根据名称查找Cookie
public class CookieUtils {
    public  static Cookie findCookieByName(HttpServletRequest request ,String cookingName){
        Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for (Cookie c : cookies) {
                if (cookingName.equals(c.getName())) {
                    return c;
                }
            }
        }
        return null;
    }
}
